package com.zly.mybatisdemo;

import java.io.IOException;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("com.zly.mybatisdemo.dao")
public class MybatisDemoApplication {
    public static void main(String[] args) throws IOException {

        SpringApplication.run(MybatisDemoApplication.class,args);
//        //1.读取配置文件
//        InputStream in = Resources.getResourceAsStream("application.yml");
//        //2.创建SqlSessionFactory工厂
//        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
//        SqlSessionFactory factory = builder.build(in);
//        //3.使用工厂生产SqlSession对象
//        SqlSession session = factory.openSession();
//        //4.使用SqlSession创建Dao接口的代理对象
//        IEvent eventDAO = session.getMapper(EventImpl.class);
//        //5.使用代理对象执行方法
//        List<Event> events = eventDAO.findAllEvent();
//        for (Event event : events) {
//            System.out.println(event);
//        }
//        //6.释放资源
//        session.close();
////        in.close();
    }
}
